# -*- coding:UTF-8 -*-
'''
开发环境：PyCharm
创建日期：2025/8/20 17:11
作   者：新启典学苑-樱桃
描   述：pytest+数据驱动+requests 对注册、充值接口进行测试
       用列表存储测试数据
'''
import pytest
import requests

# phone, pwd, regname, msg, code, status
@pytest.fixture(params=[["13834563496","123456","用户1", "注册成功", "10001", 1],
                        ["13804563457","123456","用户2", "注册成功", "10001", 1],
                        ["13804563457","12345","用户2", "密码长度必须为6~18", "20108", 0]])
def zhuce_data(request):
    return request.param
def test_zhuce(zhuce_data):
    print("输入正确的数据，注册成功")
    cs = {
        "mobilephone":zhuce_data[0],
        "pwd":zhuce_data[1],
        "regname":zhuce_data[2]
    }
    url = "http://192.168.1.29:8088/futureloan/mvc/api/member/register"
    r = requests.post(url,data=cs)  # Response
    print(r.json())  # json() 方法，把响应体转成json格式的。
    assert r.json()['msg'] == zhuce_data[3]
    assert r.json()['status'] == zhuce_data[5]
    assert r.json()['code'] == zhuce_data[4]

